package Controllers
{
	import Models.Model;
	
	import flash.events.MouseEvent;
	
	import mx.events.CalendarLayoutChangeEvent;
	import mx.events.ListEvent;
	
	public class Controller
	{	
		private var model : Model;
		
		public function Controller()
		{
			model = new Model();
		}
		
		public function GetModel() : Model
		{
			return model;
		}

		public function OnCalendarChange(event : CalendarLayoutChangeEvent) : void
		{
			model.AddElement(event.newDate);
		}
		
		public function OnRowSelectionChange(event: ListEvent) : void
		{
			model.selectedIndex = event.rowIndex;
		}
		
		public function OnClearClick(event: MouseEvent) : void
		{
			model.Clear(); 
		}
		
		public function OnSortClick(event: MouseEvent) : void
		{
			model.SortArray();
		}
		
		public function OnDeleteClick(event: MouseEvent) : void
		{
			model.Delete();
		}
	}
}